package orxatas.travelme.entity;

public enum PlaceType {
	CITY, REGION, COUNTRY, CONTINENT, NATURAL, CULTURAL, POI, INFRASTRUCTURE, HOTEL, RESTAURANT, PUB, DISCO;
	
	static String t_CITY = "CITY";
	static String t_REGION = "REGION";
	static String t_COUNTRY = "COUNTRY";
	static String t_CONTINENT = "CONTINENT";
	static String t_NATURAL = "NATURAL";
	static String t_CULTURAL = "CULTURAL";
	static String t_POI = "POI";
	static String t_INFRASTRUCTURE = "INFRASTRUCTURE";
	static String t_HOTEL = "HOTEL";
	static String t_RESTAURANT = "RESTAURANT";
	static String t_PUB = "PUB";
	static String t_DISCO = "DISCO";
	
	static String SEPARATOR = "|";
	
	public static String getEnumString(PlaceType value){
		switch(value){
			case CITY: return t_CITY;
			case CONTINENT: return t_REGION;
			case COUNTRY: return t_COUNTRY;
			case CULTURAL: return t_CULTURAL;
			case DISCO: return t_DISCO;
			case HOTEL: return t_HOTEL;
			case INFRASTRUCTURE: return t_INFRASTRUCTURE;
			case NATURAL: return t_NATURAL;
			case POI: return t_POI;
			case PUB: return t_PUB;
			case REGION: return t_REGION;
			case RESTAURANT: return t_RESTAURANT;
		}
		
		//The app may break if this ocurrs.
		return "";
	}
	
	/**
	 * Transform a PlaceType list to a Troovel API format.
	 * @param ptList List of PlaceType values
	 * 
	 * @return List formated as Troovel API needs.
	 * */
	static public String toString(PlaceType [] ptList){
		String ptListFormated;
		if(ptList == null || ptList.length == 0)
			return null;
		else
			ptListFormated = getEnumString(ptList[0]);
		
		for(int i=1; i<ptList.length; i++){
			ptListFormated += SEPARATOR+getEnumString(ptList[i]);
		}
		return ptListFormated;
	}
	
	static public PlaceType toEnum(String cs){
		if(t_CITY.contentEquals(cs))
			return CITY;
		else if(t_CONTINENT.contentEquals(cs))
			return CONTINENT;
		else if(t_COUNTRY.contentEquals(cs))
			return COUNTRY;
		else if(t_CULTURAL.contentEquals(cs))
			return CULTURAL;
		else if(t_DISCO.contentEquals(cs))
			return DISCO;
		else if(t_HOTEL.contentEquals(cs))
			return HOTEL;
		else if(t_INFRASTRUCTURE.contentEquals(cs))
			return INFRASTRUCTURE;
		else if(t_NATURAL.contentEquals(cs))
			return NATURAL;
		else if(t_POI.contentEquals(cs))
			return POI;
		else if(t_PUB.contentEquals(cs))
			return PUB;
		else if(t_REGION.contentEquals(cs))
			return REGION;
		else if(t_RESTAURANT.contentEquals(cs))
			return RESTAURANT;
		
		//The app may break if this occurs.
		return null;
	}
	
}
